home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / c.dxr / 00009_Env C Logic 3.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  9.8 KB  |  233 lines

  1. global gWorld, gStates, gObjects, gCurKeyList, void, gCursorlist, sQTCharSprite, sCURSORSPRITE, gHaveNavs, gTempHotRects, gHotRects, cNullSprite
  2.  
  3. on EnterC10
  4.   if getaProp(getaProp(gStates, #BeenThere), #c10) = 0 then
  5.     Startthetimer(30, "playSound " & QUOTE & "C10vowrk.aif" & QUOTE & ", #file, 1", #EastWestTempObj)
  6.   end if
  7.   if not voidp(getaProp(gObjects, #BBallon)) then
  8.     if getaProp(getaProp(gObjects, #BBallon), #solved) = #true then
  9.       MakeDynamic(#EastWestTempObj, #State, #on)
  10.     else
  11.       MakeDynamic(#EastWestTempObj, #State, #off)
  12.     end if
  13.   else
  14.   end if
  15.   turnOnObj(#EastWestTempObj)
  16.   if getaProp(getaProp(gStates, #BeenThere), #c08) > 0 then
  17.     if (the State of the ThermometerOBJ of gObjects = #off) and (the State of the EastWestTempObj of gObjects = #off) then
  18.       PDARelease("J04m03p.mov")
  19.     end if
  20.   end if
  21. end
  22.  
  23. on ExitC10
  24.   DelObjects([getaProp(getaProp(gObjects, #eastWestMonitor), #State)])
  25. end
  26.  
  27. on DragAttr OBJref
  28.   set H to the mouseH
  29.   set V to the mouseV
  30.   set OffsetH to H - getAt(getaProp(getaProp(gObjects, #AttrAnim), #loc), 1)
  31.   set OffsetV to V - getAt(getaProp(getaProp(gObjects, #AttrAnim), #loc), 2)
  32.   set dragThis to getaProp(getaProp(gObjects, OBJref), #dragThis)
  33.   set scoreThis to getaProp(getaProp(gObjects, OBJref), #scoreThis)
  34.   if getaProp(getaProp(gObjects, dragThis), #paused) <> 1 then
  35.     set the pbPauseState of getaProp(getaProp(gObjects, dragThis), #animator) to 1
  36.     set the pbPauseState of getaProp(getaProp(gObjects, scoreThis), #animator) to 1
  37.     if GrabDragCustom(OBJref, dragThis, scoreThis, H, V, OffsetH, OffsetV) then
  38.       MakeDynamic(dragThis, #paused, 1)
  39.     else
  40.       set the loc of sprite getaProp(getaProp(gObjects, #AttrAnim), #SpriteNum) to getaProp(getaProp(gObjects, #AttrAnim), #loc)
  41.       if not voidp(getaProp(getaProp(gObjects, dragThis), #animator)) then
  42.         set the pbPauseState of getaProp(getaProp(gObjects, dragThis), #animator) to 0
  43.         set the pbPauseState of getaProp(getaProp(gObjects, scoreThis), #animator) to 0
  44.       end if
  45.     end if
  46.   end if
  47.   CursorandUpdate()
  48. end
  49.  
  50. on GrabDragCustom OBJref, dragThis, scoreThis, H, V, OffsetH, OffsetV
  51.   set OBj to getaProp(gObjects, dragThis)
  52.   cursor(getaProp(gCursorlist, #Grab))
  53.   if not voidp(getaProp(getaProp(OBj, #sound), #down)) then
  54.     stopsound(getaProp(getaProp(OBj, #sound), #down))
  55.     playSound(getaProp(getaProp(OBj, #sound), #down), #keyframeCast)
  56.   end if
  57.   set contrainRect to getConstrainRect(dragThis)
  58.   set thisSprite to getaProp(getaProp(gObjects, #AttrAnim), #SpriteNum)
  59.   repeat while the stillDown
  60.     set myLoc to point(the mouseH - OffsetH, the mouseV - OffsetV)
  61.     set the loc of sprite thisSprite to constrainLoc(myLoc, contrainRect)
  62.     CursorandUpdate()
  63.   end repeat
  64.   if not voidp(getaProp(getaProp(OBj, #sound), #UP)) then
  65.     stopsound(getaProp(getaProp(OBj, #sound), #UP))
  66.     playSound(getaProp(getaProp(OBj, #sound), #UP), #keyframeCast)
  67.   end if
  68.   cursor(getaProp(gCursorlist, #Hand))
  69.   CursorandUpdate()
  70.   if checkInsertion(OBJref, dragThis, scoreThis) then
  71.     doInsertAttr()
  72.     return 1
  73.   else
  74.     return 0
  75.   end if
  76.   CursorandUpdate()
  77. end
  78.  
  79. on constrainLoc myLoc, constrainRect
  80.   if not inside(myLoc, constrainRect) then
  81.     set H to getAt(myLoc, 1)
  82.     set V to getAt(myLoc, 2)
  83.     if H < getAt(constrainRect, 1) then
  84.       set H to getAt(constrainRect, 1)
  85.     end if
  86.     if H > getAt(constrainRect, 3) then
  87.       set H to getAt(constrainRect, 3)
  88.     end if
  89.     if V < getAt(constrainRect, 2) then
  90.       set V to getAt(constrainRect, 2)
  91.     end if
  92.     if V > getAt(constrainRect, 4) then
  93.       set V to getAt(constrainRect, 4)
  94.     end if
  95.     return point(H, V)
  96.   end if
  97.   return myLoc
  98. end
  99.  
  100. on checkInsertion OBJref, dragThis, scoreThis
  101.   if intersect(the rect of sprite getaProp(getaProp(gObjects, dragThis), #SpriteNum), getAt(getaProp(getaProp(gObjects, OBJref), #insertRect), 1)) > 0 then
  102.     set weatherName to the name of cast the castNum of sprite getaProp(getaProp(gObjects, scoreThis), #SpriteNum)
  103.     set theWeather to getaProp(getaProp(getaProp(gObjects, scoreThis), #stateList), weatherName)
  104.     set wonOnThisTry to score(#weatherObj, theWeather)
  105.     if wonOnThisTry = 1 then
  106.       if the winC of the weatherObj of gObjects = 0 then
  107.         DelObjects([#grabAndDragHotSpot])
  108.         MakeDynamic(#weatherObj, #winC, 1)
  109.         Startthetimer(1, "genExitKF #c02c")
  110.       else
  111.         if the winC of the weatherObj of gObjects = 1 then
  112.           if getaProp(getaProp(gStates, #BeenThere), #d01) then
  113.             MakeDynamic(#weatherObj, #winC, 2)
  114.           end if
  115.         else
  116.         end if
  117.       end if
  118.     end if
  119.     return 1
  120.   else
  121.   end if
  122.   return 0
  123. end
  124.  
  125. on calcCousinsStateInt OBJref
  126.   if not voidp(gObjects) then
  127.     set myallstates to getaProp(getaProp(gObjects, OBJref), #allStates)
  128.     return getOne(myallstates, getaProp(getaProp(gObjects, OBJref), #currentState))
  129.   else
  130.     return 5
  131.   end if
  132. end
  133.  
  134. on doInsertAttr
  135.   set myAnimObj to getaProp(gObjects, #AttrAnim)
  136.   set startpoint to the loc of sprite getaProp(myAnimObj, #SpriteNum)
  137.   playSound("C11slot.aif", #keyframeCast)
  138.   set mySeasonsAnim to getaProp(getaProp(gObjects, #SeasonsAnim), #SpriteNum)
  139.   set myAnimSprite to getaProp(getaProp(gObjects, #AttrAnim), #SpriteNum)
  140.   set OrbitObjSpriteNum to getaProp(myAnimObj, #SpriteNum)
  141.   set endPoint to getaProp(myAnimObj, #endPoint)
  142.   drawCurvedline(OrbitObjSpriteNum, startpoint, endPoint, mySeasonsAnim)
  143.   set finalendPoint to getaProp(myAnimObj, #finalendPoint)
  144.   drawLine(OrbitObjSpriteNum, endPoint, finalendPoint)
  145.   DelObjects([#grabAndDragHotSpot])
  146.   set the loc of sprite getaProp(getaProp(gObjects, #SeasonsAnim), #SpriteNum) to point(20000, 20000)
  147.   set the loc of sprite getaProp(getaProp(gObjects, #AttrAnim), #SpriteNum) to point(20000, 20000)
  148.   set the loc of sprite getaProp(getaProp(gObjects, #slotTop), #SpriteNum) to getaProp(getaProp(gObjects, #slotTop), #offloc)
  149. end
  150.  
  151. on waitfor ticks
  152.   set timeNow to the timer
  153.   set endTime to timeNow + ticks
  154.   repeat while the timer < endTime
  155.   end repeat
  156. end
  157.  
  158. on donothing
  159. end
  160.  
  161. on EnterC11
  162.   set aMaxInt to calcCousinsStateInt(#EastWestTempObj)
  163.   set bMaxInt to calcCousinsStateInt(#windspeedObj)
  164.   set cMaxInt to calcCousinsStateInt(#ThermometerOBJ)
  165.   Startthetimer(1, "SetGraphSpriteTrails")
  166.   set AmpList to [0.84999999999999998, 0.69999999999999996, 1.0, 0.5, 0.19999999999999998]
  167.   set Amplitude to getAt(AmpList, bMaxInt)
  168.   setaProp(getaProp(getaProp(gObjects, #WindSpeedGraphObj), #graphList), #Amplitude, Amplitude)
  169.   setaProp(getaProp(getaProp(gObjects, #EastWestBalloonGrafObj), #graphList), #maxRandomInt, aMaxInt)
  170.   setaProp(getaProp(getaProp(gObjects, #WindSpeedGraphObj), #graphList), #maxRandomInt, bMaxInt)
  171.   setaProp(getaProp(getaProp(gObjects, #Rocketc08GraphObj), #graphList), #maxRandomInt, cMaxInt)
  172.   MakeDynamic(#EastWestBalloonGrafObj, #graphList, getaProp(getaProp(gObjects, #EastWestBalloonGrafObj), #graphList))
  173.   MakeDynamic(#WindSpeedGraphObj, #graphList, getaProp(getaProp(gObjects, #WindSpeedGraphObj), #graphList))
  174.   MakeDynamic(#Rocketc08GraphObj, #graphList, getaProp(getaProp(gObjects, #Rocketc08GraphObj), #graphList))
  175.   MakeDynamic(#AttrAnim, #paused, 0)
  176. end
  177.  
  178. on ExitC11
  179.   cleanUpmySeasonsAnim()
  180.   ResetGraphSpriteTrails()
  181.   DelObjects([#weatherObj, #ControlPanelParent, #windSpeedEnable, #EastWestBalloonEnable, #TempRocketEnable, #Reset, #screensOffLeft, #screensOffRight, #barGraphBkgnd, #C11AccessControlPanel, #AccessYes, #AccessNo, #flashQT, #transAttrQT, #grabAndDragHotSpot, #slotTop])
  182. end
  183.  
  184. on setGraphSpriteTrails
  185.   set refList to [#WindSpeedGraphObj, #EastWestBalloonGrafObj, #Rocketc08GraphObj]
  186.   repeat with ref in refList
  187.     set the trails of sprite getaProp(getaProp(gObjects, ref), #SpriteNum) to 1
  188.   end repeat
  189. end
  190.  
  191. on ResetGraphSpriteTrails
  192.   set refList to [#WindSpeedGraphObj, #EastWestBalloonGrafObj, #Rocketc08GraphObj]
  193.   repeat with ref in refList
  194.     set the trails of sprite getaProp(getaProp(gObjects, ref), #SpriteNum) to 0
  195.     set the ink of sprite getaProp(getaProp(gObjects, ref), #SpriteNum) to 36
  196.   end repeat
  197. end
  198.  
  199. on cleanUpmySeasonsAnim
  200.   set mySeasonsAnim to 17
  201.   set the loc of sprite mySeasonsAnim to point(20000, 20000)
  202.   set the castNum of sprite mySeasonsAnim to cNullSprite
  203.   set the ink of sprite mySeasonsAnim to 36
  204. end
  205.  
  206. on calcC11grafState
  207.   if voidp(getaProp(gObjects, #ThermometerOBJ)) or voidp(getaProp(gObjects, #windspeedObj)) or voidp(getaProp(gObjects, #EastWestTempObj)) then
  208.     MakeDynamic(#weatherObj, #State, #off)
  209.   else
  210.     if (getaProp(getaProp(gObjects, #WindSpeedGraphObj), #loc) = getaProp(getaProp(gObjects, #WindSpeedGraphObj), #onloc)) and (getaProp(getaProp(gObjects, #EastWestBalloonGrafObj), #loc) = getaProp(getaProp(gObjects, #EastWestBalloonGrafObj), #onloc)) and (getaProp(getaProp(gObjects, #Rocketc08GraphObj), #loc) = getaProp(getaProp(gObjects, #Rocketc08GraphObj), #onloc)) then
  211.       MakeDynamic(#weatherObj, #State, #Access)
  212.     else
  213.       if (getaProp(getaProp(gObjects, #ThermometerOBJ), #State) = #on) or (getaProp(getaProp(gObjects, #windspeedObj), #State) = #on) or (getaProp(getaProp(gObjects, #EastWestTempObj), #State) = #on) then
  214.         MakeDynamic(#weatherObj, #State, #Graphing)
  215.       else
  216.         MakeDynamic(#weatherObj, #State, #off)
  217.       end if
  218.     end if
  219.   end if
  220.   return the State of the weatherObj of gObjects
  221. end
  222.  
  223. on calcC11AttrState
  224.   if (getaProp(getaProp(gObjects, #ThermometerOBJ), #solved) = 1) and (getaProp(getaProp(gObjects, #windspeedObj), #solved) = 1) and (getaProp(getaProp(gObjects, #EastWestTempObj), #solved) = 1) and (getaProp(getaProp(gObjects, #WindSpeedGraphObj), #loc) = getaProp(getaProp(gObjects, #WindSpeedGraphObj), #onloc)) and (getaProp(getaProp(gObjects, #EastWestBalloonGrafObj), #loc) = getaProp(getaProp(gObjects, #EastWestBalloonGrafObj), #onloc)) and (getaProp(getaProp(gObjects, #Rocketc08GraphObj), #loc) = getaProp(getaProp(gObjects, #Rocketc08GraphObj), #onloc)) then
  225.     return #Attr
  226.   end if
  227.   return the State of the weatherObj of gObjects
  228. end
  229.  
  230. on playC11lor
  231.   playSound("C11lor.aif", #keyframeCast)
  232. end
  233.